package com.szholly.pro.watergas_server.ps.android.service;

import java.util.ArrayList;
import java.util.List;

import com.szholly.pro.watergas_server.common.data.DataUtil;
import com.szholly.pro.watergas_server.ps.android.bean.QcTaskParam;
import com.szholly.pro.watergas_server.ps.android.common.DateTime;
import com.szholly.pro.watergas_server.ps.android.common.ValidUtils;
import com.szholly.data.general.GlobalParameter;
import com.szholly.data.general.RowBase;

/**
 * 任务策略
 *
 * 2017/6/15 <br/>
 *
 * @author Joey Huang QQ:273179370）
 */
public abstract class QcTaskStrategy {
	protected QcOperationService mOperationService;
	protected QcParameterService mParameterService = QcParameterService.INSTANCE;

	public QcTaskStrategy(QcOperationService mOperationService) {
		this.mOperationService = mOperationService;
	}

	/**
	 * 获取运维任务列表
	 */
	public List<RowBase> getTaskList(QcTaskParam taskParam) throws Exception {
		throw new Exception("功能待开发");
	}


	/**
	 * 添加运维任务
	 */
	public RowBase addTask(QcTaskParam taskParam) throws Exception {
		throw new Exception("功能待开发");
	}

	/**
	 * 删除运维任务
	 */
	public void deleteTask(QcTaskParam taskParam) throws Exception {
		throw new Exception("功能待开发");
	}

	/**
	 * 删除运维任务和内容
	 */
	public void deleteProcessedTask(QcTaskParam taskParam) throws Exception{
		throw new Exception("功能待开发");
	}

	/**
	 * 获取运维任务详情初始化
	 */
	public RowBase getProcessedTaskInitData(QcTaskParam taskParam) throws Exception{
		throw new Exception("功能待开发");
	}

	/**
	 * 获取运维任务初始化
	 */
	public RowBase getTaskInitData(QcTaskParam taskParam) throws Exception{
		throw new Exception("功能待开发");
	}

	/**
	 * 保存运维任务
	 */
	public void saveTask(QcTaskParam taskParam) throws Exception{
		throw new Exception("功能待开发");
	}

	/**
	 * 更改运维任务
	 */
	public void updateTask(QcTaskParam taskParam) throws Exception{
		throw new Exception("功能待开发");
	}

	/**
	 * 完成运维任务
	 */
	protected final void preFinishOperationTask(String taskCode, String desc) throws Exception {
		ValidUtils.hasText(taskCode, "任务编号不能为空");
		List<GlobalParameter> parms = new ArrayList<GlobalParameter>();
		parms.add(new GlobalParameter("taskCode", taskCode));
		parms.add(new GlobalParameter("desc", desc));
		parms.add(new GlobalParameter("type", "1"));
		parms.add(new GlobalParameter("endTime", new DateTime().toString()));
		String sql = "update OPERATION_TASK t set t.task_desc = @desc,t.Task_Status = @type,t.END_TIME =to_date(@endTime,'yyyy-mm-dd hh24:mi:ss') where t.TASK_CODE = @taskCode";
		DataUtil.ExecuteUpdateSql(sql, parms);
	}
}
